-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: landmark for trigger_teleport #510
Conversation
|
I suppose BunnymodXT/HLSDK/engine/eiface.h Line 424 in a0cc469
Then perform all needed conditions, if result is positive then received edict and its keyvalue we can store all in our custom container at the same index (e.g. BunnymodXT/HLSDK/engine/eiface.h Lines 297 to 304 in a0cc469
In our function we can iterate over that container and check whether the In the end, clean the container every time the server is shutdown ( BunnymodXT/HLSDK/engine/eiface.h Lines 446 to 448 in a0cc469
|
Thanks for the suggestion, I think this should be better. |
Apparently this does not work on Windows atm. Not sure why. |
BunnymodXT/modules/ServerDLL.cpp
Outdated
pev->origin = pev->origin + offset; | ||
// have to offset by some HULL because of origin z diff | ||
auto is_duck = pev->button & (IN_DUCK) || pev->flags & (FL_DUCKING); | ||
if (is_duck) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const Vector VEC_HULL_MIN(-16, -16, -36);
const Vector VEC_DUCK_HULL_MIN(-16, -16, -18);
auto hull_offset = is_duck ? VEC_DUCK_HULL_MIN : VEC_HULL_MIN;
pev->origin[2] += hull_offset[2];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many repetition of this HULL values, maybe future refactor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many repetition of this HULL values, maybe future refactor?
Surely.
I know that now in the code these HULL values are declared several times in scope of different functions, but with a future refactor all this will be declared once in some header.
So let it be like this for now.
BunnymodXT/modules/ServerDLL.cpp
Outdated
return true; | ||
} | ||
|
||
void TriggerTpKeepsMomentumRestore(Vector prev_vel, Vector prev_view, Vector prev_angles, Vector prev_basevelocity, entvars_t *pev, enginefuncs_t *pEngfuncs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void TriggerTpKeepsMomentumRestore(entvars_t *pev, Vector prev_vel, Vector prev_view, Vector prev_angles, Vector prev_basevelocity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rebase of another other commit, maybe ill change it there instead
BunnymodXT/modules/ServerDLL.cpp
Outdated
Vector vecAngles = Vector(0, pev->v_angle.y, 0); | ||
Vector vecForward; | ||
|
||
pEngfuncs->pfnAngleVectors(vecAngles, vecForward, nullptr, nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServerDLL::GetInstance().pEngfuncs->pfnAngleVectors(vecAngles, vecForward, nullptr, nullptr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase of another commit
The reason why it does not work on Windows is because the hook was not declared in the BunnymodXT/BunnymodXT/modules/ServerDLL.cpp Line 128 in 76aefb2
BunnymodXT/BunnymodXT/modules/ServerDLL.cpp Line 183 in 76aefb2
|
BunnymodXT/modules/HwDLL.cpp
Outdated
@@ -7529,6 +7529,7 @@ HOOK_DEF_3(HwDLL, int, __cdecl, SV_SpawnServer, int, bIsDemo, char*, server, cha | |||
if (ret) { | |||
Interprocess::WriteMapChange(CustomHud::GetTime(), server); | |||
lastLoadedMap = server; | |||
ServerDLL::GetInstance().ClearTPLandmarks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. You know, clearing in SV_SpawnServer
is generally not bad, because it is called when a new map starts, changelevels and similar events, and it is called before the engine calls DispatchKeyValue
ServerDeactivate
(funcs.pfnServerDeactivate from DLL_FUNCTIONS
table) is also called in those events and also before DispatchKeyValue
, but the difference is that it also covers other events such as disconnect
At that point clearing in ServerDeactivate
looks a bit safer, because for example if you are disconnected and you are in the menu, you know that the data will already be cleared, and in the case of SV_SpawnServer
you need load map to clear this old data
So personally, I would advise hooking ServerDeactivate
from the server-side (fortunately it doesn’t require patterns) and including a comment at the beginning of its function about the difference in data cleanup compared to SV_SpawnServer
You may also need to hook ServerActivate
to track its state, because HLSDK does this to avoid unnecessary calls to ServerDeactivate
, take a look at the highlighted lines: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/client.cpp#L685-L708
ServerActivate
could be hooked from exported server table too, so not need to worries about patterns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by tracking ServerActivate
state? Tracking g_serveractive
? So there needs to be either another pattern for that static value or BXT own static value for g_serveractive
? Seems like a lot of extra work. I think clearing data on load is fine unless you are adamant about it then I can make some changes for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you read the highlighted lines carefully, you will understand that you don’t need to intercept that g_serveractive
variable at all. Let me show you a concept of how this can be done without patterns.
// Global variable
bool g_serveractive = false;
// Find "DLL_FUNCTIONS funcs;" in the server module for the declaration location
ORIG_ServerActivate = funcs.pfnServerActivate;
ORIG_ServerDeactivate = funcs.pfnServerDeactivate;
HOOK_DEF_0(ServerDLL, void, __cdecl, ServerDeactivate)
{
// https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/client.cpp#L685-L708
if (g_serveractive)
{
g_serveractive = false;
// Peform any shutdown operations here...
}
ORIG_ServerDeactivate();
}
HOOK_DEF_3(ServerDLL, void, __cdecl, ServerActivate, edict_t*, pEdictList, int, edictCount, int, clientMax)
{
g_serveractive = true;
ORIG_ServerActivate(pEdictList, edictCount, clientMax);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on load is fine unless you are adamant about it then I can make some changes for that.
Well I'd fine with it in general because I don't think there would a cases when you want to access that data while being not on the server, and even so there seems a validation checks is done, so I'd like to say fine, but ServerDeactivate
would be a nicer option in fact, maybe it should be done with future refactoring then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally understood what you mean. I just wonder if it is worth it. Do you think it is good to pursue this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github going slow. I agree it should be in the future refactor. This PR is another rebase of another PR so I am not very confident to make some changes here.
&& !strcmp(pkvd->szClassName, "trigger_teleport") | ||
&& !strcmp(pkvd->szKeyName, "landmark") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of string comparisons that happen all the time (?), especially for an optional feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made me paranoid so I debug print it. This is only called when a new server is started. Every time a new server is started, a lot of string comparisons like this happen to parse entities in BSP. This one is just one extra entity available in the game.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise good to go ig
Thanks |
Something from CSS. Something like this rehlds/ReGameDLL_CS#950
I have to hijack the "message" field becausetrigger_teleportation
does not have its own key value function.I don't really hope this thing is merged but I want it stay around in case anyone wanting to testlandmark teleportation in GoldSrc. It is a neat feature, very simple and effective.Here is the map to test, along with its source
arte_confused.zip